
clear
// use "intermediatedata\lichess"
//
// keep if timecontrol=="180+0" | timecontrol=="300+0"
//

use "intermediatedata\lichess180"
append using "intermediatedata\lichess300"

xtset game turn


gen diff_eval=s.eval2/100 if abs(l.eval2)<=500

replace diff_eval=-diff_eval if mod(turn,2)==0

bys game (turn): gen prev_move=move[_n-1]

gen prev_check=strpos(prev_move,"+")>0
gen prev_capture=strpos(prev_move,"x")>0

// duplicates tag movercode turn prev_check prev_capture piecesonboard, gen(myDuplicate)
// keep if myDuplicate


reghdfe diff_eval timetaken if timecontrol=="180+0", absorb(movercode#turn)
estadd local  fes "Player-Turn"
estadd local  tc "3 min"
estadd local iv "--"
est sto ols180




reghdfe diff_eval timetaken if timecontrol=="180+0", absorb(movercode#turn#prev_check#prev_capture)
estadd local  fes "Player-Turn-Capture-Check"
estadd local  tc "3 min"
estadd local iv "--"
est sto ols180_r1



reghdfe diff_eval timetaken if timecontrol=="180+0", absorb(movercode#turn#piecesonboard)
estadd local  fes "Player-Turn-Pieces"
estadd local  tc "3 min"
estadd local iv "--"
est sto ols180_r2


reghdfe diff_eval timetaken if timecontrol=="300+0", absorb(movercode#turn)
estadd local  fes "Player-Turn"
estadd local  tc "5 min"
estadd local iv "--"
est sto ols300




reghdfe diff_eval timetaken if timecontrol=="300+0", absorb(movercode#turn#prev_check#prev_capture)
estadd local  fes "Player-Turn-Capture-Check"
estadd local  tc "5 min"
estadd local iv "--"
est sto ols300_r1



reghdfe diff_eval timetaken if timecontrol=="300+0", absorb(movercode#turn#piecesonboard)
estadd local  fes "Player-Turn-Pieces"
estadd local  tc "5 min"
estadd local iv "--"
est sto ols300_r2


reghdfe timetaken i.timecontrol1, absorb(movercode#turn)


ivreghdfe diff_eval (timetaken=timecontrol1), absorb(movercode#turn)
estadd local iv "Time Control"
estadd local  fes "Player-Turn"
estadd local  tc "3 and 5 min"
est sto iv180_300



ivreghdfe diff_eval (timetaken=timecontrol1), absorb(movercode#turn#prev_check#prev_capture)
estadd local iv "Time Control"
estadd local  fes "Player-Turn-Capture-Check"
estadd local  tc "3 and 5 min"
est sto iv180_300_r1

ivreghdfe diff_eval (timetaken=timecontrol1), absorb(movercode#turn#piecesonboard)
estadd local iv "Time Control"
estadd local  fes "Player-Turn-Pieces"
estadd local  tc "3 and 5 min"
est sto iv180_300_r2

label var diff_eval "Evaluation Change"
label var timetaken "Seconds Spent"


esttab ols180 ols300 iv180_300 using "exhibits/motivation.tex", replace keep(timetaken)  scalar("widstat F-statistic" "tc Time Control" "fes Fixed Effects" "iv Instrument" ) se label tex nonotes
esttab ols180 ols300 iv180_300 using "exhibits/motivation_nostar.tex", replace keep(timetaken) nostar scalar("widstat F-statistic" "tc Time Control" "fes Fixed Effects" "iv Instrument" ) se label tex nonotes
esttab ols180 ols180_r1 ols180_r2 ols300 ols300_r1 ols300_r2 iv180_300, keep(timetaken) scalar("widstat F-statistic" "tc Time Control"  "fes Fixed Effects" "iv Instrument" ) se label

esttab iv180_300 iv180_300_r1 iv180_300_r2, keep(timetaken) scalar("widstat F-statistic" "tc Time Control"  "fes Fixed Effects" "iv Instrument" ) se label

